package com.piper.core.enums;

import com.piper.core.exception.AbstractServiceException;

/**
 * core模块的异常集合
 */
public enum CoreExceptionEnum implements AbstractServiceException {

    /**
     * token异常
     */
    NO_CURRENT_USER(700, "当前没有登录的用户"),
    TOKEN_EXPIRED(700, "token过期"),
    TOKEN_ERROR(700, "token验证失败"),
    PERMISSION_ERROR(800, "没有访问该资源的权限"),

    /**
     * 签名异常
     */
    SIGN_ERROR(700, "签名验证失败"),

    /**
     * 其他
     */
    WRITE_ERROR(500, "渲染界面错误"),
    PAGE_PARAM_ERROR(400, "获取分页参数异常"),

    /**
     * 文件上传
     */
    FILE_READING_ERROR(400, "FILE_READING_ERROR!"),
    FILE_NOT_FOUND(400, "FILE_NOT_FOUND!"),
    UPLOAD_ERROR(500, "上传文件出错"),

    /**
     * 错误的请求
     */
    USER_NOT_EXISTED(401, "用户不存在"),
    REQUEST_NULL(400, "请求有错误"),
    REMOTE_SERVICE_NULL(400, "远程服务不存在"),
    SERVICE_ERROR(500, "服务器异常"),

    /**
     * 流异常
     */
    IO_ERROR(500, "输入输出流异常"),

    /**
     * 加密解密
     */
    ENCRYPT_ERROR(3009, "加密异常"),

    DATABASE_INSERT_ERROR(288, "数据写入异常"),
    ASYNC_ERROR(5000, "数据在被别人修改，请稍后重试");

    CoreExceptionEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    private Integer code;

    private String message;

    @Override
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
